<template>
  <div>
    <a-button type="primary" @click="download">下载模板</a-button>
  </div>
</template>
<script>
import axios from "axios";

export default {
  mounted: function(){
  },
  watch:{

  },
  props: {
    text: { type: [String] },
    displayType: { type: [String], default: 'BUTTON' },
    row: { type: [Object], default: () => { return {} } },
  },
  data() {
    return {
      visible: false,
    }
  },
  computed: {

  },
  methods: {
    showModal() {
      this.visible = true
      this.selectedRowKeys =  [this.value]
    },


    download() {
      axios({
        method: 'get',
        url: '/backend/path/download',
        params: {},
        responseType: 'blob',
      }).then((res) => {
        if (!res.data) {
          return
        }
        let url = window.URL.createObjectURL(res.data)
        let link = document.createElement('a')
        link.style.display = 'none'
        link.href = url
        //link.target="_blank"
        link.download = decodeURIComponent(res.headers.filename)
        document.body.appendChild(link)
        link.click()
        document.body.removeChild(link);
        window.URL.revokeObjectURL(link.href);
      });
    }
  }
}
</script>
